package com.hanscan.persistence.entities;

import java.io.Serializable;
import javax.persistence.*;


@Entity
@Table(name = "biotemplates")
@SequenceGenerator(name = "biotemplateGen", sequenceName = "biotemplateGen",
allocationSize = 1)
@NamedQueries(
{
    @NamedQuery(name = "getAllBioTemplates",
    query = "SELECT g FROM BioTemplate g "),
    @NamedQuery(name = "findBioTemplatesByBioTemplateId",
    query = "SELECT g FROM BioTemplate g " +
    "WHERE g.bioTemplateId=?1")
})
public class BioTemplate implements Serializable
{

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE,
    generator = "biotemplateGen")
    private Long bioTemplateId;

    //Atributos
    @Column(nullable = false)
    private byte[] templateData;
    @Column(nullable = false)
    private boolean isEncrypted;
    @Column(nullable = false)
    private int fingerNumber;
    @Column(nullable = false)
    private boolean duress;

    //Relaciones
    @JoinColumn(nullable = false)
    @ManyToOne(fetch = FetchType.LAZY, cascade= CascadeType.ALL, optional = false)
    private IdentificationFormat templateFormat;

    public BioTemplate()
    {
    }

    public BioTemplate(Long bioTemplateId, byte[] templateData,
            boolean isEncrypted, int fingerNumber, boolean duress, User user,
            IdentificationFormat templateFormat)
    {
        this.bioTemplateId = bioTemplateId;
        this.templateData = templateData;
        this.isEncrypted = isEncrypted;
        this.fingerNumber = fingerNumber;
        this.duress = duress;
        this.templateFormat = templateFormat;
    }


    public Long getBioTemplateId()
    {
        return bioTemplateId;
    }

    public void setBioTemplateId(Long bioTemplateId)
    {
        this.bioTemplateId = bioTemplateId;
    }

    public boolean isDuress()
    {
        return duress;
    }

    public void setDuress(boolean duress)
    {
        this.duress = duress;
    }

    public int getFingerNumber()
    {
        return fingerNumber;
    }

    public void setFingerNumber(int fingerNumber)
    {
        this.fingerNumber = fingerNumber;
    }

    public boolean isIsEncrypted()
    {
        return isEncrypted;
    }

    public void setIsEncrypted(boolean isEncrypted)
    {
        this.isEncrypted = isEncrypted;
    }

    public byte[] getTemplateData()
    {
        return templateData;
    }

    public void setTemplateData(byte[] templateData)
    {
        this.templateData = templateData;
    }

    public IdentificationFormat getTemplateFormat()
    {
        return templateFormat;
    }

    public void setTemplateFormat(IdentificationFormat templateFormat)
    {
        this.templateFormat = templateFormat;
    }

}
